<include file="../Public/_top" />
<div class="content">
  <div class="wrap">
      <div class="con_side">
          <ul class="nav">
            <if condition="$userGroup eq 4"><li><a href="{:U('public/Report/Graden')}">园级报告</a></li></if>
            <li><a href="{:U('public/Report/index')}">班级报告</a></li>
            <li  class="cursor"><a href="{:U('public/Report/OneReport')}">个体报告</a></li>
            <li><a href="{:U('public/Report/GradeSelfTestReport')}">班级自测报告</a></li>
            <li><a href="{:U('public/Report/OneSelfTestReport')}">个体自测报告</a></li>
          </ul>
        </div>
        <div class="con_main">
          <div class="con_tit">
            <span>筛选条件</span>
            <ul class="con_tit_ul">
              <li>
                <a href="javascript:;" onclick="selectChildren(this);" id="file_type">测试年份</a>
                <ul class="children">
                  <volist name="year" id="year">
                  <li><a href="javascript:;"onclick="selectYear(this,{$year});">{$year}</a></li>
                </volist>
                </ul>
              </li>
              <li>
                <a href="javascript:;" onclick="selectChildren(this);" id="resource_type">测试季度</a>
                <ul class="children">
                  <li><a href="javascript:;" onclick="selectNumber(this,1);">春季</a></li>
                  <li><a href="javascript:;" onclick="selectNumber(this,2);">秋季</a></li>
                </ul>
              </li>
              <if condition="$userGroup neq 5">
              <li>
                <a href="javascript:;" onclick="selectChildren(this);">选择年级</a>
                <ul class="children">
                  <li><a href="javascript:;" onclick="selectClass(this,1);">大班</a></li>
                  <li><a href="javascript:;" onclick="selectClass(this,2);">中班</a></li>
                  <li><a href="javascript:;" onclick="selectClass(this,3);">小班</a></li>
                  <li><a href="javascript:;" onclick="selectClass(this,4);">混龄班</a></li>
                </ul>
              </li>
              </if>
              <if condition="$userGroup neq 5">
              <li>
                <a href="javascript:;" onclick="selectChildren(this);">选择班级</a>
                <ul class="children" id="grade_list"></ul>
              </li>
              </if>
              <li>
              <input type="hidden" id="number">
              <input type="hidden" id="year">
              <input type="hidden" id="Class">
              <input type="hidden" id="class_type">
              <div href="javascript:;" onclick="select_filter();" style="background:#f68d04;margin-left:15px;width:70px;text-align:center; color:#efefef;line-height: 45px;cursor:pointer;">确定</div></li>
            </ul>
            <div class="search_wrap">
              <input class="search_inp" type="text" id="name" placeholder="按姓名搜索">
              <input class="search_btn" type="submit" value="" onclick="select_filter();">
            </div>
          </div>
            <div class="con_tit">
                <table class="table table_title t4">
                  <tr>
                    <td>报告名</td>
                    <td>操作</td>
                  </tr>
                </table>
            </div>
            <div class="con_box" id="studentList"></div>
        </div>
    </div>
</div>
<script>
$("#year").val("");
$("#number").val("");
$("#Class").val("");
var userGroup="<?php echo $userGroup; ?>";
var classId="<?php echo $classId; ?>";
if(userGroup==5){
    $.ajax({
    type: "GET",
    url:"{:U('public/Report/getStudentList')}",
    data:"is_report=1&p=1&Class="+classId,
    dataType:"json",
    success:function(data){
        appendHtml(data);
    }
  });
}
 //追加html
function appendHtml(data){
    $("#studentList").html("");
    $("#studentList").append(data.data);
    var html="<div class='pagebox'>";
    if(data.nowPage>1 ){
        page=data.nowPage-1;
        html+="<a href=\"javascript:getList("+page+")\">上一页</a>";
    }
    for (var i = 1; i <=data.totalPages; i++) {
        if(i==data.nowPage){
            html+="<a href=\"javascript:getList("+i+")\" class='on'>"+i+"</a>";
        }else{
            html+="<a href=\"javascript:getList("+i+")\" >"+i+"</a>";  
        }
    };
    if(data.totalPages>1 && data.nowPage<data.totalPages){
        page=data.nowPage+1;
        html+="<a href=\"javascript:getList("+page+")\" id=\"getList\">下一页</a>";
    }
    html+="</div>";
    $("#studentList").append(html); 
}

//查看更多
function getList(page){
    p=page;
    ajaxBang();
}
//筛选条件
function select_filter(){
  $(".children").css('display','none');
  var Class=$("#Class").val();
  var number=$("#number").val();
  var year=$("#year").val();
  var name=$("#name").val();
  var class_type=$("#class_type").val();
  p=1;
  if(name==""){
    if(year==""){
      alert("请选择测试年份");
      return;
    }
    if(number==""){
      alert("请选择测试次数");
      return;
    }
    if(userGroup==5){
      Class=classId;
    }else{
      if(Class==""){
        alert("请选择班级或输入学生姓名");
        return;
      }
    }
  }
  $.ajax({
    type: "GET",
    url:"{:U('public/Report/getStudentList')}",
    data:"is_report=1&p=1&number="+number+"&year="+year+"&Class="+Class+"&name="+name+"&class_type="+class_type,
    dataType:"json",
    success:function(data){
      appendHtml(data);
    }
  });
}
//请求事件
function ajaxBang(){
  var class_type=$("#class_type").val();
  $.ajax({
    type: "GET",
    url:"{:U('public/Report/getStudentList')}",
    data:"is_report=1&p="+p+"&number="+number+"&year="+year+"&Class="+Class+"&class_type="+class_type,
    dataType:"json",
    success:function(data){
      appendHtml(data);
    }
  });
}
function selectChildren(cate){
  $(".children").css('display','none');
  $(cate).next().css('display', 'block');
}
function selectYear(cate,year){
  $(cate).parent().nextAll().children().css('background','');
  $(cate).parent().prevAll().children().css('background','');
  $(cate).css('background','#f3a33a');
  $("#year").val(year);
}
function selectNumber(cate,number){
  $(cate).parent().nextAll().children().css('background','');
  $(cate).parent().prevAll().children().css('background','');
  $(cate).css('background','#f3a33a');
  $("#number").val(number);
}
function selectClass(cate,Class){
  $(cate).parent().nextAll().children().css('background','');
  $(cate).parent().prevAll().children().css('background','');
  $(cate).css('background','#f3a33a');
  $("#class_type").val(Class);

  var number = $("#number").val();
  var year   = $("#year").val();
  $.ajax({
    type: "GET",
    url:"{:U('public/Report/getGradeByClassType')}",
    data:"class_type="+Class+'&is_report=1&test_number='+number+'&year='+year,
    dataType:"json",
    success:function(data){
      $("#grade_list").html("");
      $("#grade_list").append(data);
    }
  });
}
function selectGrade(cate,grade){
  $("#Class").val(grade);
  $(cate).parent().nextAll().children().css('background','');
  $(cate).parent().prevAll().children().css('background','');
  $(cate).css('background','#f3a33a');
}
function sendStudentReport(id){
  $.ajax({
    type: "GET",
    url:"{:U('public/Report/sendStudentReport')}",
    data:"id="+id,
    dataType:"text",
    success:function(data){
      window.location.href=window.location.href;
    }
  });
}
function deleteReport(rpt_id){
  if(confirm("确定删除该报告？")){
    $.ajax({
      type: "GET",
      url:"{:U('public/Report/deleteReport')}",
      data:"rpt_id="+rpt_id,
      dataType:"text",
      success:function(data){
        window.location.href=window.location.href;
      }
    });
  }
}
</script>
<include file="../Public/_foot" />